﻿package mortal.game.view.submitBug
{
    import com.gengine.utils.*;
    import com.mui.controls.*;
    import extend.language.*;
    import flash.events.*;
    import flash.utils.*;
    import mortal.component.window.*;
    import mortal.game.events.*;
    import mortal.game.manager.*;
    import mortal.game.mvc.*;
    import mortal.game.view.common.*;
    import mortal.mvc.core.*;
    import mortal.mvc.interfaces.*;

    public class SubmitBugWindow extends BaseWindow
    {
        private var _btnSummit:GButton;
        private var _txtInput:GTextInput;
        private var _tipTextField:GTextFiled;
        private const _sendLiftTime:int = 10000;
        private static var _instance:SubmitBugWindow;
        private static var _mySendTime:int = 0;

        public function SubmitBugWindow(param1:ILayer = null)
        {
            super(param1);
            setSize(500 + 54, 380 + 75);
            title = Language.getString(11707);
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            var _loc_1:Number = 75;
            var _loc_2:Number = 50;
            pushUIToDisposeVec(UIFactory.bg(10, 34, 490 + _loc_2, 50 + _loc_1, this));
            var _loc_3:* = Language.getString(11708);
            _loc_3 = _loc_3 + Language.getString(11709);
            _loc_3 = _loc_3 + Language.getString(11710);
            _loc_3 = _loc_3 + Language.getString(11711);
            _loc_3 = _loc_3 + Language.getString(11712);
            this._tipTextField = UIFactory.gTextField("", 16, 41, 480 + _loc_2, 42 + _loc_1, this);
            this._tipTextField.multiline = true;
            this._tipTextField.wordWrap = true;
            this._tipTextField.htmlText = _loc_3;
            this._txtInput = UIFactory.gTextInput(10, 87 + _loc_1, 490 + _loc_2, 260, this);
            this._txtInput.maxChars = 200;
            this._txtInput.defaultText = Language.getString(11713);
            this._btnSummit = UIFactory.gButton(Language.getString(11714), 240, 355 + _loc_1, 60, 22, this);
            this._btnSummit.configEventListener(MouseEvent.CLICK, this.onBtnSummit);
            return;
        }// end function

        protected function onBtnForum(event:MouseEvent) : void
        {
            BrowerUtil.getUrl("http://gm.duowan.com/user/center/centerWeb.do");
            return;
        }// end function

        protected function onBtnSummit(event:Event) : void
        {
            var _loc_2:String = null;
            var _loc_3:Array = null;
            if (this._txtInput.text == "" || this._txtInput.text == this._txtInput.defaultText)
            {
                MsgManager.showRollTipsMsg(Language.getString(11715));
                return;
            }
            if (this._txtInput.text.length < 5)
            {
                MsgManager.showRollTipsMsg(Language.getString(11716));
                return;
            }
            _loc_2 = this._txtInput.htmlText.replace(/[<]+[^>]*[>]""[<]+[^>]*[>]/g, "");
            if (this.cheakContent(_loc_2))
            {
                _loc_3 = new Array(1, Language.getString(11717), _loc_2);
                Dispatcher.dispatchEvent(new DataEvent(EventName.ComplainSumbit, _loc_3));
                this.hide();
            }
            return;
        }// end function

        private function cheakContent(param1:String) : Boolean
        {
            var _loc_2:* = FilterText.instance.setFilterColorStr(param1);
            if (_loc_2 != param1)
            {
                this._txtInput.htmlText = _loc_2;
                MsgManager.showRollTipsMsg(Language.getString(11718));
                return false;
            }
            if (_mySendTime != 0 && getTimer() - _mySendTime < this._sendLiftTime)
            {
                MsgManager.showRollTipsMsg(Language.getString(11719));
                return false;
            }
            _mySendTime = getTimer();
            return true;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            this._tipTextField.dispose(param1);
            this._tipTextField = null;
            this._txtInput.dispose(param1);
            this._txtInput = null;
            this._btnSummit.dispose(param1);
            this._btnSummit = null;
            super.disposeImpl(param1);
            return;
        }// end function

        public static function get instance() : SubmitBugWindow
        {
            if (!_instance)
            {
                _instance = new SubmitBugWindow;
            }
            return _instance;
        }// end function

    }
}
